<jsp:directive.page import="com.lowagie.text.Document"/>
<jsp:directive.page import="com.lowagie.text.pdf.PdfWriter"/>
<jsp:directive.page import="com.lowagie.text.Paragraph"/> 
<jsp:directive.page import="java.lang.*"/>
<jsp:directive.page import="java.sql.*"/>
<jsp:directive.page import="java.io.*"/>
<jsp:directive.page import="com.lowagie.*"/>
<jsp:directive.page import="Connectivity.ConnectionManager"/>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String reportOutputFormat = request.getParameter("reportOutputFormat")!=null ?request.getParameter("reportOutputFormat"):"N";
 String path1 = "/container/images";
String basePath1 = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path1+"/";
  
    if(reportOutputFormat!=null && reportOutputFormat.equalsIgnoreCase("E")){
    	response.setContentType("application/vnd.ms-excel");
    	response.setHeader("Content-disposition","inline; filename=ViewStaffStrength.xls");
    }
   	else if(reportOutputFormat!=null && reportOutputFormat.equalsIgnoreCase("P")){
    	response.setContentType("application/pdf");
    	response.setHeader("Content-disposition","attachment; filename=ViewStaffStrength.pdf");
    }
String printcount = request.getParameter("pcount")!=null ?request.getParameter("pcount"):"2";
   int pcount=Integer.parseInt(printcount); 
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>SERVICE CALL REPORT</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>


  <body >

<!-- Embed PDF File --> 
 <OBJECT data="YourFile.pdf" TYPE="application/x-pdf" TITLE="SamplePdf"  WIDTH=200 HEIGHT=100>  
  
 
  <% 
//response.setContentType("application/pdf");      
//response.setHeader("content-disposition","attachment; filename="+"monthwise.pdf");  
       Document document=new Document();
       PdfWriter.getInstance(document,new FileOutputStream("hello.pdf"));
      document.open();  
      document.add(new Paragraph("Hello Pdf"));
      document.close(); 
    
  Connection con1=ConnectionManager.getConnection();
  
   int call_performed_id=0;
   String address="-",phone_no="-";
   String complaint_id="",issue_closed_date="",issue_closed_time="",customer_name="",call_date="",action_taken="",nature_fault="",call_time="",call_type="",item_details="",emp_name="",mtaken="",mgiven="",pfp="",remark="";
  if(request.getParameter("call_performed_id")!=(""))
  {call_performed_id=Integer.parseInt(""+(request.getParameter("call_performed_id")));}
  if(call_performed_id>0)
  {
   CallableStatement cstmt = null;
		ResultSet calldisplayrs = null;
		 String url ="/Genius/CallPerformedServlet?status=I&call_performed_id="+call_performed_id;
		out.println("<a href="+url+">Click for Pdf</a>");
	
		
		    out.println("<Br><br>-----------------------callperformedid="+call_performed_id+"------------------------------------------------------------------------------");
		    
			cstmt = con1.prepareCall("{?=call fun_retrieve_callperformed(?,?)}");
			cstmt.registerOutParameter(1, Types.OTHER);
			cstmt.setInt(2, call_performed_id);
			cstmt.setObject(3, calldisplayrs);
			
			con1.setAutoCommit(false);
			cstmt.execute();
			
			calldisplayrs =(ResultSet) cstmt.getObject(1);	
 	
  while(calldisplayrs.next())
{
 
  issue_closed_date=""+calldisplayrs.getString(1);
  issue_closed_time=calldisplayrs.getString(2);
  complaint_id=calldisplayrs.getString(3);
  customer_name=calldisplayrs.getString(4);
  call_date=calldisplayrs.getString(5);
  call_time=calldisplayrs.getString(6);
  call_type=calldisplayrs.getString(7);
  nature_fault=calldisplayrs.getString(8);
  item_details=calldisplayrs.getString(9);
   emp_name=calldisplayrs.getString(10);
   action_taken=calldisplayrs.getString(11);
  mtaken=calldisplayrs.getString(12);
  mgiven=calldisplayrs.getString(13);
  pfp=calldisplayrs.getString(14);
  remark=calldisplayrs.getString(15);             
  address=calldisplayrs.getString(16);             
  phone_no=calldisplayrs.getString(17);             



  }

  String space="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

  for(int i=0;i<pcount;i++){
   %>

   
  <table border=1   bordercolor="black" cellspacing=1 cellpadding=3>
 
  <tr><td align=center >
 
  
  <image src="<%=basePath1%>Companyprint.jpg" height=119 width=900><br><br></td></tr>
  <tr><td align=middle colspan=10><b><font size=5>SERVICE CALL REPORT</font></b></td></tr>
  <tr><td>
  
  <table  bordercolor="black" cellspacing=2 cellpadding=1 width=100%>
  <tr>
  <td colspan=1   width=30%><b>DATE:</b><%=issue_closed_date %></td>
  <td colspan=1 width=30%><b>TIME:</b><%=issue_closed_time %></td>
  <td colspan=1 width=30%><b>COMPLAINT ID:</b><%=complaint_id %></td>
  </tr>
  </table>
  </td></tr>
   
   <tr>
   <td>
   
   
   <table  bordercolor="black" cellspacing=2 cellpadding=1 width=100%>
  <tr>
  <td colspan=1   width=30%><b>CUSTOMER NAME:</b><%=customer_name%></td>
  <td colspan=1   width=30%><b>ADDRESS :</b><%=address%></td>
   </tr>
  </table>
 
   
   
   
   </td>
   </tr>
   
   <tr>
   <td>
   
   
   <table  bordercolor="black" cellspacing=2 cellpadding=1 width=100%>
  <tr>
  <td colspan=1   width=30%><b>NATURE OF FAULT :</b><%=nature_fault.toUpperCase()%></td>
  <td colspan=1   width=30%><b>CONTACT NO  :</b><%=phone_no%></td>
   </tr>
  </table>
 
   
   
   
   </td>
   </tr>
   
      
   
  <tr></tr>  
  
    <!-- ----CALL LOCK TABLE STARTS--> 
  <tr>
  
  <td colspan=10>
<table  bordercolor="black" cellspacing=2 cellpadding=1 width=100%>
  <tr>
  <td colspan=1 width=20% align=center><b>CALL LOCK DATE</b></td>
  <td colspan=1 width=20% align=center><b>CALL LOCK TIME</b></td>
  <td colspan=1 width=20% align=center><b>CALL TYPE</b></td>
  <td colspan=1 width=20% align=center><b>ITEM DETAILS</b></td>
  <td colspan=1 width=20% align=center><b>EMPLOYEE NAME</b></td>
  </tr>
  </table>
</td>
  </tr>
 
  <tr>
  <td colspan=10>
<table  bordercolor="black" cellspacing=2 cellpadding=1 width=100%>
  <tr>
  <td colspan=1 width=20% align=center><%=call_date %></td>
  <td colspan=1 width=20% align=center><%=call_time %></td>
  <td colspan=1 width=20% align=center><%=call_type %></td>
  <td colspan=1 width=20% align=center><%=item_details %></td>
  <td colspan=1 width=20% align=center><%=emp_name %></td>
  </tr>
  </table>
</td>
  </tr>
  
<tr></tr> 
  <!-- ----CALL LOCK TABLE ENDS--> 
   
   <tr><td ><b>ACTION TAKEN :</b></b><%=space %><u><%=action_taken.toUpperCase()%></u><br><br><br>  </td></tr>
   <tr></tr>
  <!-- ----material TABLE STARTS--> 
  <tr>
  
  <td colspan=10>
<table  bordercolor="black" cellspacing=2 cellpadding=1 width=100%>
  <tr>
  <td colspan=1 width=20% align=center><b>MATERIAL TAKEN</b></td>
  <td colspan=1 width=20% align=center><b>MATERIAL GIVEN</b></td>
  <td colspan=1 width=20% align=center><b>PENDING FOR PARTS</b></td>
 
  </tr>
  </table>
</td>
  </tr>
 
 
 
  <tr>
  <td colspan=10>
<table  bordercolor="black" cellspacing=2 cellpadding=1 width=100%>
  <tr>
  <td colspan=1 width=20% align=center><%=mtaken.toUpperCase()%><br><br></td>
  <td colspan=1 width=20% align=center><%=mgiven.toUpperCase() %><br><br></td>
  <td colspan=1 width=20% align=center><%=pfp.toUpperCase() %><br><br></td>
 
  </tr>
  </table>
</td>
  </tr>
  
<tr></tr> 
  <!-- ----material TABLE ENDS--> 
   <tr><td coslpan=10><b>REMARK :</b><%=space %><%=remark.toUpperCase()%><br><br></td></tr>
   <tr></tr>   
   
   
   
   
   
   
   
   
   
   
   <tr>
   <td colspan=10>
   <table  bordercolor="black" cellspacing=2 cellpadding=1 width=100% >
  <tr>
  <td colspan=1  width=50% align=center><BR><BR><BR><BR>EMPLOYEE SIGNATURE </td>
  <td colspan=1  width=50% align=center><BR><BR><BR><BR>CUSTOMER'S SIGNATURE & STAMP  </td>
 
  </tr>
  </table>
  
  </table>
  
  
 
  <%if (i<1){ %> <br><br>
  <hr width=100% style="border:1 dashed " color="BLACK" size="1"> 

    <br> <br>     <%} }%>
  
   <%
	String clickUrl ="/Genius/form/general/CallStatus.jsp?status=I&call_performed_id="+call_performed_id;
	 
 %>
   <td></td>
    </tr>
   <TR></TR>
  </table>
<!-- <a  href="/Genius/form/general/CallStatus.jsp?status=I&call_performed_id=184&reportOutputFormat=P">PDF</a>  	  
 -->  
	<%-- <script> function openFormat(formName, clickUrl,formatType, pageOrientation){
	
		var submitForm = eval("window.document." + formName);
		
		if(formatType=='P')
			submitForm.action= "<%=basePath%>form/jsp_common/PDFReport.jsp?clickUrl="+clickUrl+"reportOutputFormat=&pageOrientation=";
		else
			submitForm.action="<%=basePath%>form/jsp_common/ExcelReport.jsp?clickUrl="+clickUrl+";
			
     	submitForm.submit();
	}	
	</script> --%>
  <%} %>
  </body>
</html>
